﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Globalization;

namespace Microsoft.Forums.OfflineStore
{
    /// <summary>
    /// Additional Forum object information 
    /// </summary>
    public partial class Forum 
    {
        private bool newForum;
        private bool moderator;
        private string brandOfForum;
        private string localeOfForum;
        private int unreadPostCount;

        /// <summary>
        /// Occurs when a post is added to this forum
        /// </summary>
        public event Action<Guid> PostAdded;

        /// <summary>
        /// Occurs when a thread is added to this forum
        /// </summary>
        public event Action<Guid> ThreadAdded;
        
        /// <summary>
        /// get/set the Brand associated with the forum
        /// </summary>
        [NotInDatabase()]
        public string Brand
        {
            get { return brandOfForum; }
            set { brandOfForum = value; }
        }

        /// <summary>
        /// get/set the Locale associated with the forum
        /// </summary>
        [NotInDatabase()]
        public string Locale
        {
            get { return localeOfForum; }
            set { localeOfForum = value; }
        }

        /// <summary>
        /// Gets or sets the unread post count.
        /// </summary>
        /// <value>The unread post count.</value>
        [NotInDatabase()]
        public int UnreadPostCount
        {
            get
            {
                return unreadPostCount;
            }
            set
            {
                if (unreadPostCount != value)
                {
                    unreadPostCount = value;
                    PropertyChanged(this, new PropertyChangedEventArgs("UnreadPostCount"));
                }
            }
        }

        /// <summary>
        /// Override returns forum name instead of object type
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return this.DisplayName;
        }

        /// <summary>
        /// gets/sets indication of whether or not user is a moderator of the forum
        /// </summary>
        [NotInDatabase()]
        public bool IsModerator
        {
            get
            {
                return (moderator);
            }
            set
            {
                moderator = value;
            }
        }

        /// <summary>
        /// gets/sets indication of whether or not it is a new forum
        /// </summary>
        [NotInDatabase()]
        public bool IsNewForum
        {
            get
            {
                return (newForum);
            }
            set
            {
                newForum = value;
            }
        }



        /// <summary>
        /// Called when a post  is added.
        /// </summary>
        /// <param name="postIdAdded">The post id added.</param>
        public void OnPostAdded(Guid postIdAdded)
        {
            if (PostAdded != null)
            {
                PostAdded(postIdAdded);
            }
        }

        /// <summary>
        /// Called when a thread is added
        /// </summary>
        /// <param name="postIdAdded">The post id added.</param>
        public void OnThreadAdded(Guid threadIdAdded)
        {
            if (ThreadAdded != null)
            {
                ThreadAdded(threadIdAdded);
            }
        }
    }
}
